﻿using System;
using PluginSample2.Common;
using Plugins.UserControls;
using Utils;

namespace PluginSample2.Historical
{
	[Serializable]
	internal class EngineSettings : EngineSettingsBase, ICopyable<EngineSettings>, ICloneable<EngineSettings>
	{
		#region Attributes

		private readonly DateSelectorData _dateOptions;
		private readonly CustomDataParametersData _customDataParameters;

		#endregion

		#region Properties

		public DateTime? StartDate
		{
			get { return _dateOptions.StartDate; }
			set { _dateOptions.StartDate = value; }
		}

		public DateTime? EndDate
		{
			get { return _dateOptions.EndDate; }
			set { _dateOptions.EndDate = value; }
		}

		public bool UseAllDays
		{
			get { return _dateOptions.UseAllDays; }
			set { _dateOptions.UseAllDays = value; }
		}

		public bool GenerateDailyCharts
		{
			get { return _customDataParameters.GenerateDailyChart; }
			set { _customDataParameters.GenerateDailyChart = value; }
		}

		public bool ChartsOnlyOnOperatedDays
		{
			get { return _customDataParameters.ChartsOnlyOnOperatedDays; }
			set { _customDataParameters.ChartsOnlyOnOperatedDays = value; }
		}

		public bool ShowOperations
		{
			get { return _customDataParameters.ShowOperations; }
			set { _customDataParameters.ShowOperations = value; }
		}

		public bool ExecureInParallel
		{
			get { return _customDataParameters.ExecuteInParallel; }
			set { _customDataParameters.ExecuteInParallel = value; }
		}

		#endregion

		#region Public Methods

		public EngineSettings(StrategyControlData customOptions, DateSelectorData dateOptions, HourSelectorData hourOptions, StockParametersSelectorData stockParameters, StockSelectorData stockSelectionOptions, CustomDataParametersData customDataParameters)
			: base(customOptions, hourOptions, stockSelectionOptions, stockParameters)
		{
			_dateOptions = dateOptions;
			_customDataParameters = customDataParameters;
		}

		#endregion

		#region ICopyable

		public void Copy(EngineSettings source)
		{
			base.Copy(source);
			_dateOptions.Copy(source._dateOptions);
			_customDataParameters.Copy(source._customDataParameters);
		}

		#endregion

		#region ICloneable

		public new EngineSettings Clone()
		{
			return new EngineSettings(_customOptions.Clone(), _dateOptions.Clone(), _hourOptions.Clone(), _stockParameters.Clone(), _stockSelectionOptions.Clone(), _customDataParameters.Clone());
		}

		#endregion
	}
}